# Create your views here.
from django.shortcuts import get_object_or_404, render_to_response
from django.http import HttpResponseRedirect, HttpResponse
from django.core.urlresolvers import reverse
from django.template import RequestContext
from cartoon_us.comment.models import commentForm,comment

#posts a comment
def post_comment(request):
    if request.method=='POST':
        form=commentform(request.POST['comment'])
        c=comment(text=form.comment,poster=request.POST['poster'],to=request.POST['to'])
        has=False;
        if has:
            return  HttpResponseRedirect('profile/profile_total.html')

        # return to profile after comment has been saved
        else:
            c.save()
            return HttpResponseRedirect('profile/profile_total.html')

    # return to hompage if form cannot be loaded
    else:
        return render_to_response('profile/profile_total.html')            

#shows the comment on the profile page
def view(request):
    return render_to_response('profile/profile_total.html',{'comment':comment.objects.get(id=1)})
